package com.bt.dmdb.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import org.hibernate.annotations.Type;
import org.joda.time.LocalDateTime;
import com.bt.dmdb.json.converter.JsonDateDeserializer;
import com.bt.dmdb.json.converter.JsonDateSerializer;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

@Entity
@Table(name = "contact")
@SuppressWarnings("serial")
public class Contact implements java.io.Serializable
{
	
private Long id;
private String contactType;
private String firstName;
private String lastName;
private String emailId;
private String phoneNo;
private String mobileNo;

private CustomerDetails customerId;
private LoginUser createdBy;
private LoginUser updatedBy;

private LocalDateTime creationDate;


private LocalDateTime modificationDate;


public Contact(){}

public Contact(Long id, String contactType, String firstName,
		String lastName, String emailId, String phoneNo, String mobileNo,
		CustomerDetails customerId, LoginUser createdBy, LoginUser updatedBy,
		LocalDateTime creationDate, LocalDateTime modificationDate) {
	super();
	this.id = id;
	this.contactType = contactType;
	this.firstName = firstName;
	this.lastName = lastName;
	this.emailId = emailId;
	this.phoneNo = phoneNo;
	this.mobileNo = mobileNo;
	this.customerId = customerId;
	this.createdBy = createdBy;
	this.updatedBy = updatedBy;
	this.creationDate = creationDate;
	this.modificationDate = modificationDate;
}




@Id
@GeneratedValue(generator = "contactIG", strategy = GenerationType.TABLE)
@TableGenerator(name = "contactIG", table = "jpa_sequences", pkColumnName = "name", pkColumnValue = "Contact", allocationSize = 10, valueColumnName = "next_hi_value")
public Long getId() {
	return id;
}

public void setId(Long id) {
	this.id = id;
}

@Column(name = "contact_type", nullable = false, length = 50)
public String getContactType() {
	return contactType;
}

public void setContactType(String contactType) {
	this.contactType = contactType;
}

@Column(name = "first_name", nullable = false, length = 50)
public String getFirstName() {
	return firstName;
}

public void setFirstName(String firstName) {
	this.firstName = firstName;
}

@Column(name = "last_name", nullable = false, length = 50)
public String getLastName() {
	return lastName;
}

public void setLastName(String lastName) {
	this.lastName = lastName;
}

@Column(name = "email", nullable = false, length = 50)
public String getEmailId() {
	return emailId;
}

public void setEmailId(String emailId) {
	this.emailId = emailId;
}

@Column(name = "phone_no", nullable = false, length = 50)
public String getPhoneNo() {
	return phoneNo;
}

public void setPhoneNo(String phoneNo) {
	this.phoneNo = phoneNo;
}


@Column(name = "mobile_no", nullable = false, length = 50)
public String getMobileNo() {
	return mobileNo;
}

public void setMobileNo(String mobileNo) {
	this.mobileNo = mobileNo;
}



@Column(name = "creation_date")
    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime")
    @JsonSerialize(using = JsonDateSerializer.class)
    @JsonDeserialize(using = JsonDateDeserializer.class)

public LocalDateTime getCreationDate() {
	return creationDate;
}

public void setCreationDate(LocalDateTime creationDate) {
	this.creationDate = creationDate;
}




@Column(name = "modification_date")
@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime")
@JsonSerialize(using = JsonDateSerializer.class)
@JsonDeserialize(using = JsonDateDeserializer.class)
public LocalDateTime getModificationDate() {
	return modificationDate;
}

public void setModificationDate(LocalDateTime modificationDate) {
	this.modificationDate = modificationDate;
}

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "customer_id")
public CustomerDetails getCustomerId() {
	return customerId;
}

public void setCustomerId(CustomerDetails customerId) {
	this.customerId = customerId;
}

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "created_by")
public LoginUser getCreatedBy() {
	return createdBy;
}

public void setCreatedBy(LoginUser createdBy) {
	this.createdBy = createdBy;
}


@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "updated_by")
public LoginUser getUpdatedBy() {
	return updatedBy;
}

public void setUpdatedBy(LoginUser updatedBy) {
	this.updatedBy = updatedBy;
}


}